<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateEnergyStorageTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('energy_storager_stations', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('enterprise_id')->comment('所属企业id');
            $table->string('name')->comment('名称');
            $table->string('zone')->comment('地区:省市区');
            $table->string('address')->comment('详细地址');
            $table->string('director')->nullable(true)->comment('负责人');
            $table->string('mobile')->nullable(true)->comment('联系电话');
            $table->string('remarks')->nullable(true)->comment('备注');
            $table->timestamps();
        });
        
        //储能
        Schema::create('energy_storagers', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('energy_storager_station_id')->comment('储能站id');
            $table->string('device_id')->comment('标识');
            $table->string('brand')->comment('品牌');
            $table->string('type')->nullable(true)->comment('型号');
            $table->string('status')->nullable(true)->default('在线')->comment('状态: 在线、离线、未激活、故障');
            $table->string('remarks')->nullable(true)->comment('备注');
            //电池
            $table->string('battery_brand')->nullable(true)->comment('电池品牌');
            $table->string('begin_at')->nullable(true)->comment('起始时间');
            $table->string('production_date')->nullable(true)->comment('出厂日期');
            $table->string('battery_type')->nullable(true)->comment('类型:锂电');
            $table->string('manufacturer')->nullable(true)->comment('制造商');
            $table->string('capacity')->nullable(true)->comment('容量');
            $table->string('chip')->nullable(true)->comment('电池芯片');
            $table->string('use_type')->nullable(true)->comment('梯次利用');
            $table->string('form')->nullable(true)->comment('组成方式');
            $table->string('cooling')->nullable(true)->comment('冷却方式');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('energy_storager_stations');
        Schema::dropIfExists('energy_storagers');
        Schema::dropIfExists('energy_storager_station_has_energy_storagers');
        Schema::dropIfExists('enterprise_has_energy_storage_stations');
    }
}
